<?
session_start();

require_once('config.php');
require_once('class/cls_customer.php');

$customer			= new cls_customer();


//if (isset($_REQUEST['rid']))
        //{
			// $user->delete_user($_REQUEST['rid']);

        //}

			
 	
?>
<html>
<head>
<title>Show Sales List</title>
<link href="um_sty.css" rel="stylesheet" type="text/css">
<script language="JavaScript">
function open_calendar(obj)
{
	new_window=window.open("calendar.php?form=report&field=" + obj,"","top=50,left=400,width=575,height=140,menubar=no,toolbar=no,scrollbars=no,resizable=no,status=no");
}
</script>
</head>

<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" bgcolor="#F7F9F0">



<table id="Table_01" width="775" border="0" cellpadding="0" cellspacing="0" align="center">

	<tr>

		<td><table id="Table_01" width="775" height="32" align="center" border="0" cellpadding="0" cellspacing="0">
          <tr>
            <td width="233" height="32"><img src="images/banner.jpg" width="774" height="100" alt=""></td>
            
          </tr>
        </table>
		  <!-- End ImageReady Slices -->
		  <table id="Table_02" width="775" height="24" align="center" bgcolor="#000000" border="0" cellpadding="0" cellspacing="0">
            <tr>
              <td width="544" align="left" valign="middle">&nbsp;&nbsp;<<a  href="index.php" class="ummenu" >Home</a>		

		&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
		
		<a href="customer_service.php" class="ummenu">Customer Services</a>
		
		&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;

		<a href="contact_us.php" class="ummenu">Contact Us</a>
		
		&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;

		<a href="aboutus.php" class="ummenu">About Us</a>&nbsp;&nbsp;&nbsp;</td>
              <td width="231" height="24" align="right" valign="middle"><a href="http://66.94.233.46/babelfish/trurl_pagecontent?lp=en_ja&trurl=http%3a%2f%2fwww.umgroups.com"> </a>&nbsp;&nbsp; <a href="http://66.94.233.46/babelfish/trurl_pagecontent?lp=en_zt&trurl=http%3a%2f%2fwww.umgroups.com"> </a>&nbsp;&nbsp; <a href="http://66.94.233.46/babelfish/trurl_pagecontent?lp=en_ko&trurl=http%3a%2f%2fwww.umgroups.com"> </a>&nbsp;&nbsp;&nbsp;&nbsp;</td>
            </tr>
          </table></td>

	</tr>
	
	<tr><td>
	<table id="Table_01" width="775" border="0" cellpadding="0" cellspacing="0" align="center" bgcolor="#FFFFFF" style="border-left: 1px solid #CCCCCC; border-right: 1px solid #CCCCCC" >
	<tr>
	  <td colspan="8">&nbsp;</td>
	  </tr>
	<tr><td colspan="8" align="center">
	<form id="form1" name="report" method="post" action="admin_date_list.php">
  Get a report 
  From 
  <input name="fromdate" type="text" />
  <img src="images/calendar.gif" style="cursor: hand;" align="absmiddle" onClick="open_calendar('fromdate'); return false;"> 
  To 
  <input name="todate" type="text" />
  <img src="images/calendar.gif" style="cursor: hand;" align="absmiddle" onClick="open_calendar('todate'); return false;">
  <input type="submit" name="cmdSubmit" value="Submit" />
</form>

<?

/*
	This function is for changing the date format into "2007-6-25"
	Because, the database only accepts the date format in "Year-Month-Day"
 */
function render_date($mydate)
{
	return	strftime("%Y-%m-%d",strtotime($mydate));
}

if (isset($_POST['cmdSubmit'])) {	// checking whether it is post or not.

	$fromdate	= render_date($_POST['fromdate']);	// change the date format into "Year-Month-Day"
	$todate		= render_date($_POST['todate']); 	// change the date format into "Year-Month-Day"
	
	
	
	$sql	= "SELECT * FROM tbl_customer c , tbl_salesinfo s WHERE c.customer_id = s.customer_id AND c.date > '$fromdate' ".
				"AND c.date < '$todate' ORDER  BY  c.customer_id";
				

	/*
		These are just connecting to the database & get result according to the user input.
		It's as usual... nothing strange
	 */
	$myconn	= mysql_connect("localhost","root","");
	mysql_select_db("soethida",$myconn);
	
	$result	= mysql_query($sql);
	
	
	while ($row = mysql_fetch_array($result)) {
		echo $row['firstname']."&nbsp;&nbsp;&nbsp;&nbsp;".$row['lastname']."&nbsp;&nbsp;&nbsp;&nbsp;".$row['email']."&nbsp;&nbsp;&nbsp;&nbsp;".$row['date']."&nbsp;&nbsp;&nbsp;&nbsp;".$row['brand']."&nbsp;&nbsp;&nbsp;&nbsp;".$row['type']."&nbsp;&nbsp;&nbsp;&nbsp;".$row['qty']."<br />";
	}
	mysql_close($myconn);
}
?>
	
	</td></tr>
      <tr>
        <td>
		<table width="775px" align="center">
          <tr>
            <td align="center">&nbsp;</td>
            <td align="center">&nbsp;</td>
            <td align="center">&nbsp;</td>
            <td>&nbsp;</td>
			 <td>&nbsp;</td>
			 <td>&nbsp;</td>
			 <td>&nbsp;</td>
			 <td>&nbsp;</td>
			 <td>&nbsp;</td>
          </tr>
          <tr>
            <td align="center">No</td>
            <td align="center">First Name</td>
            <td align="center">Last Name</td>
            <td align="center">Email</td>
			<td align="center">Date</td>
			<td align="center">Brand</td>
			<td align="center">Type</td>
			<td align="center">Quantity</td>
			<td>&nbsp;</td>
          </tr>
          <tr>
            <td colspan="8"><hr width="100%"></td>
          </tr>
          <?
			
		$pageno	 	= isset($_REQUEST['page']) 	? $_REQUEST['page'] : 1;	

		$object		= $customer->get_customer($pageno);
		//print_r ($object);
		$pagecount	= $object['pagecount'];
		
		$numrows	= $object['numrows'];		
		
		unset($object['numrows'],$object['pagecount']);
		
		if (count($object) > 0)
		{
				
			foreach ($object as $row) {
?>
          <tr>
            <td align="center"><?= $row['id'] ?></td>
            <td align="center"><?= $row['firstname'] ?></td>
            <td align="center"><?= $row['lastname'] ?></td>
            <td align="center"><?= $row['email'] ?></td>
			<td align="center"><?= $row['date'] ?></td>
			<td align="center"><?= $row['brand'] ?></td>
			<td align="center"><?= $row['type'] ?></td>
			<td align="center"><?= $row['qty'] ?></td>
			<td>&nbsp;</td>
          </tr>
          <tr>
            <td colspan="8"><hr width="100%"></td>
          </tr>
                    <?			}//for
		}//if		

?>
		           
            <tr>
            <td colspan="5">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<? 
				require_once("class/cls_utility.php");
				$utility	= new utility();
				//$utility->paging("",$pagecount,$numrows,$qrystr,$pageno); 
				$utility->paging("",$pagecount,$numrows,"",$pageno);
			?></td>
			<td colspan="3" align="right"><a href="admin.php">Back to Admin Page.</a>&nbsp;&nbsp;&nbsp;</td>
          </tr>
        </table></td>
      </tr>
      <tr>
        <td height="2" bgcolor="#CCCCCC"></td>
      </tr>
      <tr>
        <td><table align="center" border="0" cellpadding="0" cellspacing="0" width="775" id="table6" bgcolor="#FFFFFF" style="border-bottom: 3px solid #DF8A0B;">

			<tr>

				<td width="100%" height="30" class="foot">&nbsp;</td>
			</tr>
		</table></td>
      </tr>
</table></td></tr>
</body>
</html>
